Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error: (wrong-type-argument keymapp nil) #1073

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsntn
Copy link
Contributor

@jsntn jsntn commented Nov 22, 2024

This error occurs because evil-local-set-key expects a valid keymap, but at the time it's being called from my end, the buffer may not have been properly initialized with a major mode that sets up the keymaps. See error details below,

Debugger entered--Lisp error: (wrong-type-argument keymapp nil)
  define-key(nil "q" my-dict-quit-window)
  evil-local-set-key(normal "q" my-dict-quit-window)
  (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window))
  (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window)))
  (save-current-buffer (set-buffer buf) (setq buffer-read-only nil) (erase-buffer) (insert def) (goto-char (point-min)) (local-set-key (kbd "q") 'my-dict-quit-window) (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window))))
  (progn (setq buf (get-buffer-create my-dict-buffer-name)) (save-current-buffer (set-buffer buf) (setq buffer-read-only nil) (erase-buffer) (insert def) (goto-char (point-min)) (local-set-key (kbd "q") 'my-dict-quit-window) (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window)))) (if (eq (current-buffer) buf) nil (if (null (setq win (get-buffer-window buf))) (switch-to-buffer-other-window buf) (select-window win))))
...

This error occurs because evil-local-set-key expects a valid keymap, but at the time it's being called from my end, the buffer may not have been properly initialized with a major mode that sets up the keymaps. See error details below,

-------

Debugger entered--Lisp error: (wrong-type-argument keymapp nil)
  define-key(nil "q" my-dict-quit-window)
  evil-local-set-key(normal "q" my-dict-quit-window)
  (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window))
  (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window)))
  (save-current-buffer (set-buffer buf) (setq buffer-read-only nil) (erase-buffer) (insert def) (goto-char (point-min)) (local-set-key (kbd "q") 'my-dict-quit-window) (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window))))
  (progn (setq buf (get-buffer-create my-dict-buffer-name)) (save-current-buffer (set-buffer buf) (setq buffer-read-only nil) (erase-buffer) (insert def) (goto-char (point-min)) (local-set-key (kbd "q") 'my-dict-quit-window) (if (and (boundp 'evil-mode) evil-mode) (progn (evil-local-set-key 'normal (kbd "q") 'my-dict-quit-window)))) (if (eq (current-buffer) buf) nil (if (null (setq win (get-buffer-window buf))) (switch-to-buffer-other-window buf) (select-window win))))
...
@redguardtoo
Copy link
Owner

Try

diff --git a/lisp/init-dictionary.el b/lisp/init-dictionary.el
index 75ac6337..380bef26 100644
--- a/lisp/init-dictionary.el
+++ b/lisp/init-dictionary.el
@@ -59,7 +59,8 @@
           ;; quit easily
           (local-set-key (kbd "q") 'my-dict-quit-window)
           (when (and (boundp 'evil-mode) evil-mode)
-            (evil-local-set-key 'normal "q" 'my-dict-quit-window)))
+            (my-run-with-idle-timer 1 (lambda ()
+                                        (evil-local-set-key 'normal "q" 'my-dict-quit-window)))))
         (unless (eq (current-buffer) buf)
           (if (null (setq win (get-buffer-window buf)))
               (switch-to-buffer-other-window buf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants